package com.helloniu.wb.tools {

import mx.core.UIComponent;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
import com.helloniu.fl.util.Tool;

public class ResizeBox extends UIComponent {
    public function ResizeBox() {
        //buttonMode = useHandCursor = true;
        setupListeners();
    }

    protected function setupListeners():void{
        addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
        addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
    }

    private function mouseUpHandler(event:MouseEvent):void {
        resizeType = -1;
    }

    private function mouseDownHandler(event:MouseEvent):void {
        resizeType = -1;
        var currPoint:Point = new Point(event.localX, event.localY);

        for(var i:int = 0; i < rectArr.length; i++) {
            if((rectArr[i] as Rectangle).containsPoint(currPoint)) {
                resizeType = i;
                return;
            }
        }
    }

    protected var resizeType:Number = -1;
    protected var rectArr:Array = null;
    protected var startP:Point;
    protected var offset:Number = 5;
    protected var areaWidth:Number = 10;
    protected var areaHeight:Number = 10;

}
}